using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuanLyKhachHang.BUS
{
	#region using
	using System.Data;
	using QuanLyKhachHang.DAO;
	using QuanLyKhachHang.DTO;
	#endregion
	public class KhachHangBUS
	{
		private KhachHangDAO objDAO;
		public KhachHangBUS(String strPath)
		{
			objDAO = new KhachHangDAO(strPath);
		}

        public DataSet SearchKhachHang(KhachHangDTO objDto)
        {
            DataSet ds;
            try
            {
                ds = objDAO.SearchKhachHang(objDto);
                return ds;
            }
            catch (System.Exception e)
            {
                throw new Exception(e.Message, e.InnerException);
            }
        }

		public DataSet SelectAll()
		{
			DataSet ds;
			try
			{
				ds = objDAO.SelectAll();
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
		}

		public DataSet SelectByID(int makh)
		{
			DataSet ds;
			try
			{
				ds = objDAO.SelectByID(makh);
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
		}

		public bool Insert(KhachHangDTO obj)
		{
			try
			{
				return objDAO.Insert(obj);
			}
			catch
			{
				return false;
			}
		}

        public bool InsertAndConcerns(KhachHangDTO objkh, TrichThuong_ChietKhauDTO objttck)
        {
            try
            {
                return objDAO.InsertAndConcerns(objkh, objttck);
            }
            catch
            {
                return false;
            }
        }

		public bool Delete(int makh)
		{
			try
			{
				return objDAO.Delete(makh);
			}
			catch
			{
				return false;
			}
		}

		public bool Update(KhachHangDTO obj)
		{
			try
			{
				return objDAO.Update(obj);
			}
			catch
			{
				return false;
			}
		}

        public bool UpdateAndConcerns(KhachHangDTO obj, TrichThuong_ChietKhauDTO objtt)
        {
            try
            {
                return objDAO.UpdateAndConcerns(obj, objtt);
            }
            catch
            {
                return false;
            }
        }

        public DataSet SelectByMADONVI(string madonvi)
        {
            DataSet ds;
            try
            {
                ds = objDAO.SelectByMADONVI(madonvi);
                return ds;
            }
            catch (System.Exception e)
            {
                throw new Exception(e.Message, e.InnerException);
            }
        }

        public DataSet SelectMAKH(string madonvi, string tenkh, string diachi)
        {
            DataSet ds;
            try
            {
                ds = objDAO.SelectMAKH(madonvi, tenkh, diachi);
                return ds;
            }
            catch (System.Exception e)
            {
                throw new Exception(e.Message, e.InnerException);
            }
        }
	}
}